package _go

//二分查找
func mySqrt(x int) int {

	if x <= 0 {
		return 0
	}

	l := 0
	r := x
	res := 0
	for l <= r {
		m := l + (r-l)/2

		if m*m <= x {
			res = m
			l = m + 1
		} else {
			r = m - 1
		}
	}
	return res
}
